package com.ship.common.business.mapping;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.ship.common.core.mapping.ContentProvider;
import com.ship.common.core.utils.konst.KonstType;
import org.springframework.stereotype.Component;

import java.lang.reflect.Field;

/**
 * @author 31463
 */
@Component
public class ConstantTypeProvider extends ContentProvider {


	@Override
	public JSONArray getOptions(Field field) {
		JSONArray e = new JSONArray();
		for(KonstType konstType: KonstType.values()){
			JSONObject jsonObject = new JSONObject();
			jsonObject.put("label", konstType.lable());
			jsonObject.put("value", konstType.value());
			e.add(jsonObject);
		}
		return e;
	}

	@Override
	public Object convert(Object currentValue, Object root, Field field) {
		return currentValue;
	}

}
